//
//  EPMNewFeatureCollectionViewCell.m
//  myXianfeng
//
//  Created by 马继鵬 on 17/4/26.
//  Copyright © 2017年 EPM. All rights reserved.
//

#import "EPMNewFeatureCollectionViewCell.h"

@interface EPMNewFeatureCollectionViewCell()
@property (weak,nonatomic)  UIImageView* imgView;
@property (weak,nonatomic)  UIButton* btn;
@end
@implementation EPMNewFeatureCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]){
        [self setupUI];
    }
    return self;
}

- (void)setupUI{
    UIImageView* imgView = [[UIImageView alloc]init];
    self.imgView = imgView;
    [self addSubview:imgView];
    
     [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.edges.mas_equalTo(UIEdgeInsetsMake(0, 0, 0, 0));
     }];
    
    UIButton* btn = [[UIButton alloc]init];
    self.btn = btn;
    [self addSubview:btn];
    btn.hidden = YES;
    [btn sizeToFit];
    [btn setImage:[UIImage imageNamed:@"icon_next"] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.bottom.equalTo(self.contentView).offset(-60);
    }];
    
}

-(void)btnClick:(id)sender{
    if (self.btnClickBlock){
        self.btnClickBlock();
    }
}


- (void)setIndexPath:(NSIndexPath *)indexPath
{
    _indexPath = indexPath;
    if (indexPath.item == 3){
        self.btn.hidden = NO;
    }else{
        self.btn.hidden = YES;
    }
    
    NSString* imgName = [NSString stringWithFormat:@"guide_40_%zd",indexPath.item+1];
    self.imgView.image = [UIImage imageNamed:imgName];
}


@end
